function sum(a: number, b: number, ...arr: number[]): number{
    console.log(arr) //[2,4]
    let total = a + b;
    for(let x of arr){
        total += x    
    }
    console.log(total) //[2,4]
    return total
}

sum(1,2,3,4)